
Imports cmplib01


Public Class frmNewTempLabel
    Inherits System.Windows.Forms.Form

    Private m_Cancelled As Boolean = False
    Private ptrMapLab As cmplib01.CampaignerLabel

#Region " Windows Form Designer generated code "

    Public Sub New()
        MyBase.New()

        'This call is required by the Windows Form Designer.
        InitializeComponent()

        'Add any initialization after the InitializeComponent() call

    End Sub

    'Form overrides dispose to clean up the component list.
    Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
        If disposing Then
            If Not (components Is Nothing) Then
                components.Dispose()
            End If
        End If
        MyBase.Dispose(disposing)
    End Sub

    'Required by the Windows Form Designer
    Private components As System.ComponentModel.IContainer

    'NOTE: The following procedure is required by the Windows Form Designer
    'It can be modified using the Windows Form Designer.  
    'Do not modify it using the code editor.
    Friend WithEvents pnlProperties As System.Windows.Forms.Panel
    Friend WithEvents txtNewLabel As System.Windows.Forms.TextBox
    Friend WithEvents lblRuleTypeName As System.Windows.Forms.Label
    Friend WithEvents btnForegroundColor As System.Windows.Forms.Button
    Friend WithEvents btnBackgroundColor As System.Windows.Forms.Button
    Friend WithEvents lblTextColor As System.Windows.Forms.Label
    Friend WithEvents lblBackgroundcolor As System.Windows.Forms.Label
    Friend WithEvents lblPreview As System.Windows.Forms.Label
    Friend WithEvents btnCancel As System.Windows.Forms.Button
    Friend WithEvents btnOK As System.Windows.Forms.Button
    Friend WithEvents lblLabelColors As System.Windows.Forms.Label
    Friend WithEvents cdlColors As System.Windows.Forms.ColorDialog
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        Dim resources As System.Resources.ResourceManager = New System.Resources.ResourceManager(GetType(frmNewTempLabel))
        Me.pnlProperties = New System.Windows.Forms.Panel()
        Me.lblLabelColors = New System.Windows.Forms.Label()
        Me.lblPreview = New System.Windows.Forms.Label()
        Me.lblBackgroundcolor = New System.Windows.Forms.Label()
        Me.lblTextColor = New System.Windows.Forms.Label()
        Me.btnBackgroundColor = New System.Windows.Forms.Button()
        Me.btnForegroundColor = New System.Windows.Forms.Button()
        Me.txtNewLabel = New System.Windows.Forms.TextBox()
        Me.lblRuleTypeName = New System.Windows.Forms.Label()
        Me.btnCancel = New System.Windows.Forms.Button()
        Me.btnOK = New System.Windows.Forms.Button()
        Me.cdlColors = New System.Windows.Forms.ColorDialog()
        Me.pnlProperties.SuspendLayout()
        Me.SuspendLayout()
        '
        'pnlProperties
        '
        Me.pnlProperties.BackColor = System.Drawing.SystemColors.ControlLight
        Me.pnlProperties.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
        Me.pnlProperties.Controls.AddRange(New System.Windows.Forms.Control() {Me.lblLabelColors, Me.lblPreview, Me.lblBackgroundcolor, Me.lblTextColor, Me.btnBackgroundColor, Me.btnForegroundColor, Me.txtNewLabel, Me.lblRuleTypeName})
        Me.pnlProperties.Location = New System.Drawing.Point(8, 8)
        Me.pnlProperties.Name = "pnlProperties"
        Me.pnlProperties.Size = New System.Drawing.Size(256, 160)
        Me.pnlProperties.TabIndex = 4
        '
        'lblLabelColors
        '
        Me.lblLabelColors.Location = New System.Drawing.Point(8, 64)
        Me.lblLabelColors.Name = "lblLabelColors"
        Me.lblLabelColors.Size = New System.Drawing.Size(184, 16)
        Me.lblLabelColors.TabIndex = 16
        Me.lblLabelColors.Text = "Label Colors: click color to change"
        '
        'lblPreview
        '
        Me.lblPreview.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
        Me.lblPreview.ForeColor = System.Drawing.SystemColors.HotTrack
        Me.lblPreview.Location = New System.Drawing.Point(8, 128)
        Me.lblPreview.Name = "lblPreview"
        Me.lblPreview.Size = New System.Drawing.Size(80, 16)
        Me.lblPreview.TabIndex = 15
        Me.lblPreview.Text = "Color Preview"
        Me.lblPreview.TextAlign = System.Drawing.ContentAlignment.MiddleCenter
        '
        'lblBackgroundcolor
        '
        Me.lblBackgroundcolor.Location = New System.Drawing.Point(152, 88)
        Me.lblBackgroundcolor.Name = "lblBackgroundcolor"
        Me.lblBackgroundcolor.Size = New System.Drawing.Size(104, 16)
        Me.lblBackgroundcolor.TabIndex = 14
        Me.lblBackgroundcolor.Text = "Background Color"
        '
        'lblTextColor
        '
        Me.lblTextColor.Location = New System.Drawing.Point(48, 88)
        Me.lblTextColor.Name = "lblTextColor"
        Me.lblTextColor.Size = New System.Drawing.Size(64, 16)
        Me.lblTextColor.TabIndex = 13
        Me.lblTextColor.Text = "Text Color"
        '
        'btnBackgroundColor
        '
        Me.btnBackgroundColor.BackColor = System.Drawing.SystemColors.Control
        Me.btnBackgroundColor.FlatStyle = System.Windows.Forms.FlatStyle.Flat
        Me.btnBackgroundColor.Location = New System.Drawing.Point(112, 88)
        Me.btnBackgroundColor.Name = "btnBackgroundColor"
        Me.btnBackgroundColor.Size = New System.Drawing.Size(32, 16)
        Me.btnBackgroundColor.TabIndex = 12
        '
        'btnForegroundColor
        '
        Me.btnForegroundColor.BackColor = System.Drawing.SystemColors.HotTrack
        Me.btnForegroundColor.FlatStyle = System.Windows.Forms.FlatStyle.Flat
        Me.btnForegroundColor.Location = New System.Drawing.Point(8, 88)
        Me.btnForegroundColor.Name = "btnForegroundColor"
        Me.btnForegroundColor.Size = New System.Drawing.Size(32, 16)
        Me.btnForegroundColor.TabIndex = 11
        '
        'txtNewLabel
        '
        Me.txtNewLabel.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
        Me.txtNewLabel.Location = New System.Drawing.Point(8, 32)
        Me.txtNewLabel.Name = "txtNewLabel"
        Me.txtNewLabel.Size = New System.Drawing.Size(233, 20)
        Me.txtNewLabel.TabIndex = 0
        Me.txtNewLabel.Text = "New Label"
        '
        'lblRuleTypeName
        '
        Me.lblRuleTypeName.Location = New System.Drawing.Point(7, 11)
        Me.lblRuleTypeName.Name = "lblRuleTypeName"
        Me.lblRuleTypeName.Size = New System.Drawing.Size(57, 16)
        Me.lblRuleTypeName.TabIndex = 10
        Me.lblRuleTypeName.Text = "Text"
        Me.lblRuleTypeName.TextAlign = System.Drawing.ContentAlignment.MiddleLeft
        '
        'btnCancel
        '
        Me.btnCancel.FlatStyle = System.Windows.Forms.FlatStyle.Flat
        Me.btnCancel.Location = New System.Drawing.Point(200, 176)
        Me.btnCancel.Name = "btnCancel"
        Me.btnCancel.Size = New System.Drawing.Size(56, 23)
        Me.btnCancel.TabIndex = 6
        Me.btnCancel.Text = "Cancel"
        '
        'btnOK
        '
        Me.btnOK.FlatStyle = System.Windows.Forms.FlatStyle.Flat
        Me.btnOK.Location = New System.Drawing.Point(136, 176)
        Me.btnOK.Name = "btnOK"
        Me.btnOK.Size = New System.Drawing.Size(56, 23)
        Me.btnOK.TabIndex = 5
        Me.btnOK.Text = "OK"
        '
        'frmNewTempLabel
        '
        Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
        Me.ClientSize = New System.Drawing.Size(274, 208)
        Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.btnCancel, Me.btnOK, Me.pnlProperties})
        Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog
        Me.Icon = CType(resources.GetObject("$this.Icon"), System.Drawing.Icon)
        Me.Name = "frmNewTempLabel"
        Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent
        Me.Text = "Campaigner Map Label"
        Me.pnlProperties.ResumeLayout(False)
        Me.ResumeLayout(False)

    End Sub

#End Region

    Public Sub New(ByRef mapL As CampaignerLabel)
        Me.New()

        ptrMapLab = mapL
        PopulateProperties()

    End Sub

    Private Sub PopulateProperties()
        ' take the existing properties and set them to the form
        txtNewLabel.Text = ptrMapLab.text
        btnForegroundColor.BackColor = ptrMapLab.foreColor
        btnBackgroundColor.BackColor = ptrMapLab.BackColor
        ' Set previewcolors
        PreviewColors()
    End Sub

    Private Sub PreviewColors()
        lblPreview.ForeColor = btnForegroundColor.BackColor
        lblPreview.BackColor = btnBackgroundColor.BackColor
    End Sub

    Private Sub SaveProperties()
        ptrMapLab.text = txtNewLabel.Text
        ptrMapLab.foreColor = btnForegroundColor.BackColor
        ptrMapLab.BackColor = btnBackgroundColor.BackColor

    End Sub

    Public ReadOnly Property Cancelled() As Boolean
        Get
            Return m_Cancelled
        End Get
    End Property

    Private Sub btnOK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOK.Click
        m_Cancelled = False
        SaveProperties()
        Me.Hide()
    End Sub

    Private Sub btnCancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCancel.Click
        m_Cancelled = True
        Me.Hide()
    End Sub

    Private Sub btnForegroundColor_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnForegroundColor.Click
        cdlColors.ShowDialog()
        btnForegroundColor.BackColor = cdlColors.Color
        PreviewColors()
    End Sub

    Private Sub btnBackgroundColor_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnBackgroundColor.Click
        cdlColors.ShowDialog()
        btnBackgroundColor.BackColor = cdlColors.Color
        PreviewColors()
    End Sub
End Class
